package gui;

import classes.CargoComissao;
import classes.CargoEfetivo;
import classes.Lotacao;
import classes.Servidor;
import java.awt.event.KeyEvent;
import org.apache.commons.lang3.StringUtils;
import erro.ConexaoException;
import erro.ConsultaException;
import erro.GeralException;
import fachada.Fachada;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import javax.swing.JOptionPane;
import javax.swing.text.MaskFormatter;

/**
 *
 * @author Roberta
 */
public class ServidorEditar extends javax.swing.JFrame {

    Servidor s = new Servidor();

    public ServidorEditar() {
        initComponents();
        this.setLocationRelativeTo(null);
        carregarCombos();

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        grupoNivel = new javax.swing.ButtonGroup();
        btSalvar = new javax.swing.JButton();
        jTabbedPane4 = new javax.swing.JTabbedPane();
        frameDadosProf = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel42 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        textEmailProf = new javax.swing.JTextField();
        jLabel45 = new javax.swing.JLabel();
        textTelSetor = new javax.swing.JTextField();
        try{ 
            javax.swing.text.MaskFormatter tel= new javax.swing.text.MaskFormatter("####-####"); 
            textTelSetor = new javax.swing.JFormattedTextField(tel); 
        } 
        catch (Exception e){ 
        }
        jLabel48 = new javax.swing.JLabel();
        cbLotacao = new javax.swing.JComboBox();
        jLabel47 = new javax.swing.JLabel();
        cbCargoC = new javax.swing.JComboBox();
        jLabel46 = new javax.swing.JLabel();
        cbCargoE = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        lbMatricula = new javax.swing.JLabel();
        panelAcesso = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        rdUsuario = new javax.swing.JRadioButton();
        jLabel16 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        rdMaster = new javax.swing.JRadioButton();
        jPanel5 = new javax.swing.JPanel();
        rdIntermediario = new javax.swing.JRadioButton();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        rdDesabilitado = new javax.swing.JRadioButton();
        jLabel17 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        textTelFunc = new javax.swing.JTextField();
        try{ 
            javax.swing.text.MaskFormatter tel= new javax.swing.text.MaskFormatter("####-####"); 
            textTelFunc = new javax.swing.JFormattedTextField(tel); 
        } 
        catch (Exception e){ 
        }
        frameDadosPessoais = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        textNome = new javax.swing.JTextField();
        jLabel34 = new javax.swing.JLabel();
        textEmail = new javax.swing.JTextField();
        textTel = new javax.swing.JTextField();
        try{ 
            javax.swing.text.MaskFormatter tel= new javax.swing.text.MaskFormatter("## ####-####"); 
            textTel = new javax.swing.JFormattedTextField(tel); 
        } 
        catch (Exception e){ 
        }
        textTel2 = new javax.swing.JTextField();
        try{ 
            javax.swing.text.MaskFormatter tel= new javax.swing.text.MaskFormatter("## ####-####"); 
            textTel2 = new javax.swing.JFormattedTextField(tel); 
        } 
        catch (Exception e){ 
        }
        jLabel33 = new javax.swing.JLabel();
        textRua = new javax.swing.JTextField();
        jLabel37 = new javax.swing.JLabel();
        textNumero = new javax.swing.JTextField();
        jLabel38 = new javax.swing.JLabel();
        textBairro = new javax.swing.JTextField();
        jLabel39 = new javax.swing.JLabel();
        textCidade = new javax.swing.JTextField();
        jLabel40 = new javax.swing.JLabel();
        textEstado = new javax.swing.JTextField();
        jLabel41 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        textCep = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        textNasc = new com.toedter.calendar.JDateChooser();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        checkEmail = new javax.swing.JCheckBox();
        textCpf = new javax.swing.JTextField();
        try{ 
            javax.swing.text.MaskFormatter cpf= new javax.swing.text.MaskFormatter("###.###.###-##"); 
            textCpf = new javax.swing.JFormattedTextField(cpf); 
        } 
        catch (Exception e){ 
        }
        jLabel44 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Alterar Dados do Servidor");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        btSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/salvar.png"))); // NOI18N
        btSalvar.setText("Salvar");
        btSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSalvarActionPerformed(evt);
            }
        });
        btSalvar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btSalvarKeyPressed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel42.setText("Matricula:");

        jLabel43.setText("E-mail:");

        jLabel45.setText("Telefone do setor:");

        jLabel48.setText("Lotação:");

        jLabel47.setText("Cargo Comissão:");

        cbCargoC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbCargoCActionPerformed(evt);
            }
        });

        jLabel46.setText("Cargo Efetivo:");

        jLabel10.setText("*");

        panelAcesso.setBorder(javax.swing.BorderFactory.createTitledBorder("Nível de Acesso"));

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        grupoNivel.add(rdUsuario);
        rdUsuario.setText("Usuário:");
        rdUsuario.setToolTipText("Apenas cadastra andamento das tarefas e eventos.");

        jLabel16.setForeground(new java.awt.Color(0, 102, 153));
        jLabel16.setText("Apenas cadastra agenda pessoal.");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdUsuario)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel16)
                .addContainerGap(192, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdUsuario)
                    .addComponent(jLabel16))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel12.setForeground(new java.awt.Color(0, 102, 153));
        jLabel12.setText("Nível de acesso máximo do sistema.");

        grupoNivel.add(rdMaster);
        rdMaster.setText("Administrador:");
        rdMaster.setToolTipText("Nível máximo.");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdMaster)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addContainerGap(154, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdMaster)
                    .addComponent(jLabel12))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        grupoNivel.add(rdIntermediario);
        rdIntermediario.setText("Master:");
        rdIntermediario.setToolTipText("Nível médio: Não pode alterar tarefas que não foram cadastradas por ele.");

        jLabel13.setForeground(new java.awt.Color(0, 102, 153));
        jLabel13.setText("O servidor que tem esse nível de acesso só altera");

        jLabel14.setForeground(new java.awt.Color(0, 102, 153));
        jLabel14.setText("dados das tarefas inseridas por ele.");

        jLabel15.setForeground(new java.awt.Color(0, 102, 153));
        jLabel15.setText("Não insere nível de acesso dos usuários.");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdIntermediario)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jLabel14)
                    .addComponent(jLabel13))
                .addContainerGap(119, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdIntermediario)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel15)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        grupoNivel.add(rdDesabilitado);
        rdDesabilitado.setText("Desabilitado:");

        jLabel17.setForeground(new java.awt.Color(0, 102, 153));
        jLabel17.setText("Não tem acesso ao Sistema.");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rdDesabilitado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel17)
                .addContainerGap(198, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rdDesabilitado)
                    .addComponent(jLabel17))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panelAcessoLayout = new javax.swing.GroupLayout(panelAcesso);
        panelAcesso.setLayout(panelAcessoLayout);
        panelAcessoLayout.setHorizontalGroup(
            panelAcessoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        panelAcessoLayout.setVerticalGroup(
            panelAcessoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAcessoLayout.createSequentialGroup()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jLabel9.setText("*");

        jLabel11.setText("*");

        jLabel7.setText("Telefone funcional:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel45)
                            .addComponent(jLabel43)
                            .addComponent(jLabel42)
                            .addComponent(jLabel7)
                            .addComponent(jLabel48)
                            .addComponent(jLabel47)
                            .addComponent(jLabel46))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbCargoE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbCargoC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(cbLotacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(5, 5, 5)
                                .addComponent(jLabel10))
                            .addComponent(lbMatricula)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(textEmailProf, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel11))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(textTelFunc, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(textTelSetor, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel9))))
                    .addComponent(panelAcesso, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel42, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lbMatricula))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel43)
                    .addComponent(textEmailProf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel45)
                    .addComponent(textTelSetor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(textTelFunc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel48)
                    .addComponent(cbLotacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel47)
                    .addComponent(cbCargoC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel46)
                    .addComponent(cbCargoE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(panelAcesso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout frameDadosProfLayout = new javax.swing.GroupLayout(frameDadosProf);
        frameDadosProf.setLayout(frameDadosProfLayout);
        frameDadosProfLayout.setHorizontalGroup(
            frameDadosProfLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameDadosProfLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        frameDadosProfLayout.setVerticalGroup(
            frameDadosProfLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameDadosProfLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        jTabbedPane4.addTab("Dados Profissionais", frameDadosProf);

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel8.setText("CPF:");

        jLabel36.setText("E-mail Pessoal:");

        jLabel35.setText("Nome:");

        jLabel32.setText("Telefone 1:");

        jLabel34.setText("Telefone 2:");

        jLabel33.setText("Rua:");

        jLabel37.setText("Número:");

        jLabel38.setText("Bairro:");

        jLabel39.setText("Cidade:");

        jLabel40.setText("UF:");

        jLabel41.setText("CEP:");

        jLabel1.setText("*");

        jLabel3.setText("*");

        jLabel4.setText("*");

        try{ 
            javax.swing.text.MaskFormatter cep= new javax.swing.text.MaskFormatter("#####-###"); 
            textCep = new javax.swing.JFormattedTextField(cep); 
        } 
        catch (Exception e){ 
        }

        jLabel2.setText("Data nascimento:");

        jLabel5.setText("ex.: 01/01/2011");

        jLabel6.setText("*");

        checkEmail.setText("Deseja receber informações neste e-mail?");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addContainerGap(58, Short.MAX_VALUE)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel41)
                                .addComponent(jLabel40)
                                .addComponent(jLabel39)
                                .addComponent(jLabel38)
                                .addComponent(jLabel37)
                                .addComponent(jLabel33)))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addGap(44, 44, 44)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel34)
                                .addComponent(jLabel8)
                                .addComponent(jLabel35)
                                .addComponent(jLabel32))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(textCpf, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(textCep, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap())
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(textEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addComponent(textNome, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel1))
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addComponent(textNasc, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(4, 4, 4)
                                            .addComponent(jLabel6)
                                            .addGap(18, 18, 18)
                                            .addComponent(jLabel5))
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addComponent(textTel, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel4))
                                        .addComponent(textTel2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addContainerGap(81, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(textRua, javax.swing.GroupLayout.PREFERRED_SIZE, 273, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(textNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(textBairro, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
                                        .addComponent(textCidade, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE))
                                    .addGap(279, 279, 279)))))))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jLabel36)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(checkEmail)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(textEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)))
                .addContainerGap(251, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel35))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(textCpf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5))
                        .addComponent(textNasc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel36)
                    .addComponent(textEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(checkEmail)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel32)
                    .addComponent(textTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(16, 16, 16)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel34)
                    .addComponent(textTel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel33)
                    .addComponent(textRua, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel37)
                    .addComponent(textNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel38)
                    .addComponent(textBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel39)
                    .addComponent(textCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel40)
                    .addComponent(textEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel41)
                    .addComponent(textCep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout frameDadosPessoaisLayout = new javax.swing.GroupLayout(frameDadosPessoais);
        frameDadosPessoais.setLayout(frameDadosPessoaisLayout);
        frameDadosPessoaisLayout.setHorizontalGroup(
            frameDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameDadosPessoaisLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE)
                .addContainerGap())
        );
        frameDadosPessoaisLayout.setVerticalGroup(
            frameDadosPessoaisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameDadosPessoaisLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane4.addTab("Dados Pessoais", frameDadosPessoais);

        jLabel44.setText("* Campos obrigatórios.");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jTabbedPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btSalvar))
                    .addComponent(jLabel44))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel44))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(33, 33, 33)
                        .addComponent(btSalvar)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        carregarText();

    }//GEN-LAST:event_formWindowOpened

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
    }//GEN-LAST:event_formWindowActivated

    private void btSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvarActionPerformed
        try {
            Lotacao l = new Lotacao();
            Fachada f = new Fachada();
            CargoComissao cc = new CargoComissao();
            CargoEfetivo ce = new CargoEfetivo();
            s.setMatricula(ServidorExibir.matricula);
            String cpf = textCpf.getText();
            cpf = cpf.replaceAll("[^0-9]", "");
            String nome = textNome.getText().toLowerCase().trim();
            StringTokenizer stN = new StringTokenizer(nome, " ");
            String convertido = "";
            while (stN.hasMoreTokens()) {
                String fMaiuscula = StringUtils.capitalize(stN.nextToken().trim() + " ");
                convertido += fMaiuscula;
            }
            s.setNome(convertido);
            s.setNasc(textNasc.getDate());
            s.setEmailPessoal(textEmail.getText().toLowerCase().trim());
            s.setTelefone1(textTel.getText());
            s.setCpf(cpf);
            s.setTelefone2(textTel2.getText());
            s.setTelefoneSetor(textTelSetor.getText());
            s.setTelefoneFunc(textTelFunc.getText());
            s.setEmailProf(textEmailProf.getText().toLowerCase().trim());
            if (checkEmail.isSelected()) {
                s.setEmail(1);//Se quiser receber informações no e-mail pessoal.
            } else {
                s.setEmail(0);
            }
            String rua = textRua.getText().toLowerCase().trim();
            StringTokenizer stR = new StringTokenizer(rua, " ");
            convertido = "";
            while (stR.hasMoreTokens()) {
                String fMaiuscula = StringUtils.capitalize(stR.nextToken().trim() + " ");
                convertido += fMaiuscula;
            }
            s.setRua(convertido);
            s.setNumero(textNumero.getText());
            String bairro = textBairro.getText().toLowerCase().trim();
            StringTokenizer stB = new StringTokenizer(bairro, " ");
            convertido = "";
            while (stB.hasMoreTokens()) {
                String fMaiuscula = StringUtils.capitalize(stB.nextToken().trim() + " ");
                convertido += fMaiuscula;
            }
            s.setBairro(convertido);
            String cidade = textCidade.getText().toLowerCase().trim();
            StringTokenizer stC = new StringTokenizer(cidade, " ");
            convertido = "";
            while (stC.hasMoreTokens()) {
                String fMaiuscula = StringUtils.capitalize(stC.nextToken().trim() + " ");
                convertido += fMaiuscula;
            }
            s.setCidade(convertido);
            s.setEstado(textEstado.getText().toUpperCase().trim());
            s.setCep(textCep.getText());
            int nivel = 0;
            if (rdMaster.isSelected()) {
                nivel = 1;
            } else if (rdIntermediario.isSelected()) {
                nivel = 2;
            } else if (rdUsuario.isSelected()) {
                nivel = 3;
            } else if (rdDesabilitado.isSelected()) {
                nivel = 4;
            }
            s.setNivelAcesso(nivel);
            ArrayList<Lotacao> listaLot = new ArrayList<Lotacao>();
            listaLot = f.listar(l);
            l.setLotacao_id(listaLot.get(cbLotacao.getSelectedIndex()).getLotacao_id());
            l = f.pesquisar(l);
            s.setLotacao(l);
            ArrayList<CargoComissao> listaCc = new ArrayList<CargoComissao>();
            listaCc = f.listar(cc);
            cc.setCargoC_id(listaCc.get(cbCargoC.getSelectedIndex()).getCargoC_id());
            cc = f.pesquisar(cc);
            s.setCargoC(cc);

            ArrayList<CargoEfetivo> listaCe = new ArrayList<CargoEfetivo>();
            listaCe = f.listar(ce);
            ce.setCargoE_id(listaCe.get(cbCargoE.getSelectedIndex()).getCargoE_id());
            ce = f.pesquisar(ce);
            s.setCargoE(ce);

            f.alterar(s);
            JOptionPane.showMessageDialog(null, "Servidor alterado com sucesso!");
            this.setVisible(false);
        } catch (ConexaoException ex) {
            JOptionPane.showMessageDialog(null, "Não foi possível conectar-se ao banco de dados.\n" + ex);
        } catch (ConsultaException ex) {
            JOptionPane.showMessageDialog(null, "Não foi possível alterar o servidor " + s.getNome() + ". Verifique os campos digitados.\n" + ex);
        } catch (GeralException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
            this.repaint();
        }
    }//GEN-LAST:event_btSalvarActionPerformed

    private void btSalvarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btSalvarKeyPressed
        if (KeyEvent.getKeyText(evt.getKeyCode()).equals("Enter")) {
            btSalvarActionPerformed(null);
        }
    }//GEN-LAST:event_btSalvarKeyPressed

    private void cbCargoCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCargoCActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbCargoCActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ServidorEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ServidorEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ServidorEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ServidorEditar.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new ServidorEditar().setVisible(true);
            }
        });
    }

    public static String formatarString(String cpf, String mascara) throws ParseException {
        MaskFormatter mf = new MaskFormatter(mascara);
        mf.setValueContainsLiteralCharacters(false);
        return mf.valueToString(cpf);
    }

    public void carregarText() {
        Fachada f = new Fachada();
        String cpf;
        Servidor serv = null;
        s.setMatricula(ServidorExibir.matricula);
        lbMatricula.setText(String.valueOf(s.getMatricula()));
        try {
            serv = f.pesquisar(s);

            cpf = formatarString(serv.getCpf(), ("###.###.###-##"));
            textNome.setText(serv.getNome());
            textEmail.setText(serv.getEmailPessoal());
            textCpf.setText(cpf);
            textTel.setText(serv.getTelefone1());
            textTel2.setText(serv.getTelefone2());
            textRua.setText(serv.getRua());
            textBairro.setText(serv.getBairro());
            textNumero.setText(serv.getNumero());
            textCidade.setText(serv.getCidade());
            textNasc.setDate(serv.getNasc());
            textCep.setText(serv.getCep());
            textEstado.setText(serv.getEstado());
            textEmailProf.setText(serv.getEmailProf());
            textTelSetor.setText(serv.getTelefoneSetor());
            textTelFunc.setText(serv.getTelefoneFunc());
            if (serv.getEmail() == 1) {
                checkEmail.setSelected(true);
            }
            switch (serv.getNivelAcesso()) {
                case 1:
                    rdMaster.setSelected(true);
                    break;
                case 2:
                    rdIntermediario.setSelected(true);
                    break;
                case 3:
                    rdUsuario.setSelected(true);
                    break;
                case 4:
                    rdDesabilitado.setSelected(true);
                    break;
            }
            cbCargoC.setSelectedItem(serv.getCargoC().getNome());
            cbCargoE.setSelectedItem(serv.getCargoE().getNome());
            cbLotacao.setSelectedItem(serv.getLotacao().getSigla());
        } catch (ConexaoException ex) {
            JOptionPane.showMessageDialog(null, "Não foi possível conectar-se ao banco de dados!\n" + ex);
        } catch (ConsultaException ex) {
            JOptionPane.showMessageDialog(null, "Ocorreu um erro ao tentar carregar a tela!\n" + ex);
        } catch (ParseException ex) {
            cpf = serv.getCpf();
        }
    }

    public final void carregarCombos() {
        Fachada fachada = new Fachada();
        Lotacao lot = new Lotacao();
        CargoEfetivo ce = new CargoEfetivo();
        CargoComissao cc = new CargoComissao();
        ArrayList<Lotacao> listaLot = new ArrayList<Lotacao>();
        ArrayList<CargoEfetivo> listaCe = new ArrayList<CargoEfetivo>();
        ArrayList<CargoComissao> listaCc = new ArrayList<CargoComissao>();
        try {
            listaLot = fachada.listar(lot);
            listaCe = fachada.listar(ce);
            listaCc = fachada.listar(cc);
            for (int i = 0; i < listaLot.size(); i++) {
                cbLotacao.addItem(listaLot.get(i).getSigla());
            }
            for (int cE = 0; cE < listaCe.size(); cE++) {
                cbCargoE.addItem(listaCe.get(cE).getNome());
            }
            for (int cC = 0; cC < listaCc.size(); cC++) {
                cbCargoC.addItem(listaCc.get(cC).getNome());
            }
        } catch (ConexaoException ex) {
            JOptionPane.showMessageDialog(null, "Não foi possível conectar-se ao banco de dados!\n" + ex);
        } catch (ConsultaException ex) {
            JOptionPane.showMessageDialog(null, "Ocorreu um erro ao tentar carregar a tela!\n" + ex);
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btSalvar;
    private javax.swing.JComboBox cbCargoC;
    private javax.swing.JComboBox cbCargoE;
    private javax.swing.JComboBox cbLotacao;
    private javax.swing.JCheckBox checkEmail;
    private javax.swing.JPanel frameDadosPessoais;
    private javax.swing.JPanel frameDadosProf;
    private javax.swing.ButtonGroup grupoNivel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JTabbedPane jTabbedPane4;
    public javax.swing.JLabel lbMatricula;
    public javax.swing.JPanel panelAcesso;
    private javax.swing.JRadioButton rdDesabilitado;
    private javax.swing.JRadioButton rdIntermediario;
    private javax.swing.JRadioButton rdMaster;
    private javax.swing.JRadioButton rdUsuario;
    private javax.swing.JTextField textBairro;
    private javax.swing.JTextField textCep;
    private javax.swing.JTextField textCidade;
    private javax.swing.JTextField textCpf;
    private javax.swing.JTextField textEmail;
    private javax.swing.JTextField textEmailProf;
    private javax.swing.JTextField textEstado;
    private com.toedter.calendar.JDateChooser textNasc;
    private javax.swing.JTextField textNome;
    private javax.swing.JTextField textNumero;
    private javax.swing.JTextField textRua;
    private javax.swing.JTextField textTel;
    private javax.swing.JTextField textTel2;
    private javax.swing.JTextField textTelFunc;
    private javax.swing.JTextField textTelSetor;
    // End of variables declaration//GEN-END:variables
}
